#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int is_leapyear(int year)
{
    if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

int main()
{
    int day = 0;
    int year = 0;
    int month = 0;
    int date = 0;
    scanf("%d %d %d", &year, &month, &date);
    switch (is_leapyear(year))
    {
    case 1:
        switch (month)
        {
        case 1:day = date; break;
        case 2:day = date + 31; break;
        case 3:day = date + 31 + 29; break;
        case 4:day = date + 31 + 29 + 31; break;
        case 5:day = date + 31 + 29 + 31 + 30; break;
        case 6:day = date + 31 + 29 + 31 + 30 + 31; break;
        case 7:day = date + 31 + 29 + 31 + 30 + 31 + 30; break;
        case 8:day = date + 31 + 29 + 31 + 30 + 31 + 30 + 31; break;
        case 9:day = date + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31; break;
        case 10:day = date + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30; break;
        case 11:day = date + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; break;
        case 12:day = date + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; break;
        }
        break;
    case 0:
        switch (month)
        {
        case 1:day = date; break;
        case 2:day = date + 31; break;
        case 3:day = date + 31 + 28; break;
        case 4:day = date + 31 + 28 + 31; break;
        case 5:day = date + 31 + 28 + 31 + 30; break;
        case 6:day = date + 31 + 28 + 31 + 30 + 31; break;
        case 7:day = date + 31 + 28 + 31 + 30 + 31 + 30; break;
        case 8:day = date + 31 + 28 + 31 + 30 + 31 + 30 + 31; break;
        case 9:day = date + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31; break;
        case 10:day = date + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30; break;
        case 11:day = date + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; break;
        case 12:day = date + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; break;
        }
        break;
    }

    printf("%d", day);
    return 0;
}